package com.xcity.pomelo.response;

import com.xcity.db.entity.Build;
import com.xcity.db.entity.Player;
import com.xcity.game.build.BuildLevelUpTemplate;
import com.xcity.game.build.BuildTemplate;

import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@Deprecated
@PomeloMessage(type = Message.Type.RESPONSE)
public class CreateBuildResponse extends Response {
	
	private long gold;
	private long totalGold;
	private int health;
	private BuildData buildData;
	
	public static class BuildData {
		private int id;
		private String buildName;
		private int buildId;
		private int level;
		private int price;
		private int health;
		private int maxIncome;
		private int income;
		private long createTime;
		private byte status; // 0:建造/升级中 ; 1:空闲状态; 2:休店期
		private int remainingTime;
		private String img;
		public int getId() {
			return id;
		}
		public void setId(int id) {
			this.id = id;
		}
		public String getBuildName() {
			return buildName;
		}
		public void setBuildName(String buildName) {
			this.buildName = buildName;
		}
		public int getBuildId() {
			return buildId;
		}
		public void setBuildId(int buildId) {
			this.buildId = buildId;
		}
		public int getLevel() {
			return level;
		}
		public void setLevel(int level) {
			this.level = level;
		}
		public int getPrice() {
			return price;
		}
		public void setPrice(int price) {
			this.price = price;
		}
		public int getHealth() {
			return health;
		}
		public void setHealth(int health) {
			this.health = health;
		}
		public int getMaxIncome() {
			return maxIncome;
		}
		public void setMaxIncome(int maxIncome) {
			this.maxIncome = maxIncome;
		}
		public int getIncome() {
			return income;
		}
		public void setIncome(int income) {
			this.income = income;
		}
		public long getCreateTime() {
			return createTime;
		}
		public void setCreateTime(long createTime) {
			this.createTime = createTime;
		}
		public byte getStatus() {
			return status;
		}
		public void setStatus(byte status) {
			this.status = status;
		}
		public int getRemainingTime() {
			return remainingTime;
		}
		public void setRemainingTime(int remainingTime) {
			this.remainingTime = remainingTime;
		}
		public String getImg() {
			return img;
		}
		public void setImg(String img) {
			this.img = img;
		}
	}
	
	public CreateBuildResponse(int serial, Player player, Build src) {
		super(serial);
		this.gold = player.getGold();
		this.totalGold = player.getFixedAssets();
		this.health = player.getRisk();
		BuildTemplate temp = src.getTemplate();
		BuildLevelUpTemplate lvlTemp = temp.getLevelUpTemplate(src.getLevel());
		BuildData data = new BuildData();
		data.id = src.getId();
		data.buildName = temp.getName(src.getLevel());
		data.buildId = src.getId();
		data.level = src.getLevel();
		data.price = lvlTemp.getPrice();
		data.health = lvlTemp.getRisk();
		data.maxIncome = /*lvlTemp.getMaxIncome()*/src.getMaxIncome();
		data.income = /*lvlTemp.getIncome()*/src.getIncomePerMinute();
		data.createTime = src.getCreateTime();
		data.status = src.getState().codeOfOldVersion();
		data.remainingTime = src.getLeftCD();
		data.img = temp.getImage(src.getLevel());
		this.buildData = data;
	}

	public long getGold() {
		return gold;
	}

	public void setGold(long gold) {
		this.gold = gold;
	}

	public long getTotalGold() {
		return totalGold;
	}

	public void setTotalGold(long totalGold) {
		this.totalGold = totalGold;
	}

	public int getHealth() {
		return health;
	}

	public void setHealth(int health) {
		this.health = health;
	}

	public BuildData getBuildData() {
		return buildData;
	}

	public void setBuildData(BuildData buildData) {
		this.buildData = buildData;
	}
	
}
